Fix incorrect rounding with subnormal/zero results of float multiplication#637
Conversation
|
There has to be a bug in either GCC or LLVM's libraries at least on some platforms for f128, I was able to reproduce in C llvm/llvm-project#91840. The clippy failure is from #634 (comment) |
01a7c0c to
01b0b37
Compare
|
Probably just |
|
Allowing the lint results in the contradictory so I've added a temporary |
|
CI is now green 🎉. Thanks for the help. |
| // FIXME(f16_f128): rounding error | ||
| // FIXME(#616): re-enable once fix is in nightly | ||
| // <https://github.com/rust-lang/compiler-builtins/issues/616> | ||
| "mul_f128", | ||
| "mul_f32", | ||
| "mul_f64", |
There was a problem hiding this comment.
Why will these be fixed with the nightly bump? I guess if __mul[sd]f3 don't exist since they are expected to lower to assembly, then linking the extern "C" symbols is linking to the weak ones from this library?
There was a problem hiding this comment.
Your guess is correct.
| // FIXME(f16_f128): Incorrect rounding. | ||
| // <https://github.com/llvm/llvm-project/issues/91840> | ||
| const AARCH64_SKIPPED: &[&str] = &["mul_f128"]; |
There was a problem hiding this comment.
It seems like this must have been reproduced in CI then, which is good. Any idea where the problem is coming from? https://github.com/llvm/llvm-project/blob/8598bcb9934dca16ea16d87304e00defc85d986c/compiler-rt/lib/builtins/fp_lib.h and https://github.com/llvm/llvm-project/blob/8598bcb9934dca16ea16d87304e00defc85d986c/compiler-rt/lib/builtins/fp_mul_impl.inc don't seem to have any architecture-specific behavior except for fmaxf.
There was a problem hiding this comment.
I've just reproduced the bug using the instructions from llvm/llvm-project#91840 on x86_64-unknown-linux-gnu; I don't think the bug is platform specific, just compiler-rt specific. It only shows up on AArch64 in CI as that's the only architecture tested in compiler-builtins CI that used to build the C version of the builtin in the version of compiler-builtins currently used by nightly rustc (in the build.rs that's currently used by nightly, notice how multf3.c is only included on aarch64/arm64ec, mips64 and loongarch64).
There was a problem hiding this comment.
I've updated the FIXME.
There was a problem hiding this comment.
Ah great, guess I just didn't test this on other platforms. Thanks for testing
Fix incorrect rounding with subnormal/zero results of float multiplication
Fix float multiplication that results in subnormals (or zero), and enable tests for those cases. Also remove dead code left over from when this was ported from
compiler-rt(the other branches of theifstatement are unreachable asshiftis always less thanbitsat this point). The equivalent code incompiler-rtdoes not have this bug.Fixes #616